//
const { rejects } = require('assert');
const fs = require('fs');
/* fs.readFile('./resource/content.txt',(err,data)=>{
 
 //1.回调函数的形势
    //如果出错 则抛出错误;
    if(err)throw err;
    //输出文件内容;
    console.log(data.toString());
}); */
//err --出现错误的那个参数;
//data--- 读取到的结果;

//2.promise --封装;
let p = new Promise((resolve, reject)=>{
    fs.readFile('./resource/content.txt',(err, data) =>{
        //如果出错;
        if(err) reject(err);
        //如果成功
        resolve(data);
    })

})
//调用then;
p.then(value=>{
    console.log(value.toString());
},reason=>{
    console.log(reason);
})